*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*	This program estimates OLS VAM (for samples with older lagged scores)
*	----------------------------------------------------------------------------

	args sample sch_res vtype ptype bw

*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

*	load analysis file

	use "${builddata}${city}_analysisfile`sample'`sch_res'`bw'_older_bl", clear

	foreach y in m {

		ivset, y(`y') ptype(`ptype')
			local Y=r(Y)
			local p=r(P)
			local D=r(D)

	*	conventional in the full sample

		//lagged score
		olsvam `Y' `D', 						gen(OLSVAM_`y'_flag_3yr) covs(i.year##(i.grade c.($bl_demos) c.($bl_scores))) vce(`vtype')
		schvam OLSVAM_`y'_flag_3yr,				d(`D') gen(b_OLSVAM_`y'_flag_3yr) vgen(V_OLSVAM_`y'_flag_3yr)

	}

	* save dataset
	save "${builddata}${city}_analysisfile_vam`sample'`sch_res'`bw'_older_bl_data", replace

	* save  VAMs
	keep sch b_OLSVAM_*_flag_3yr OLSVAM_*_flag_3yr
	duplicates drop

	isid sch
	qui compress
	save "${builddata}${city}_analysisfile_vam`sample'`sch_res'`bw'_older_bl", replace
